package ExerciseGroup;
/*
* 练习 ： 杨辉三角
* */
public class YangHuiTriangle {

    public static void main(String[] args) {
        //声明二维数组
        int[] arry[] = new int[10][];

        //给数组赋值
        for (int i = 0;i < arry.length;i++){
            arry[i] = new int[i + 1];

            //2.1给首末元素赋值
            arry[i][0] = 1;
            arry[i][i] = 1;

            //2.2给其他元素辅助
            if(i > 1){
                for (int j = 1;j < arry[i].length - 1; j++ ){
                    arry[i][j] = arry[i-1][j-1] + arry[i-1][j];
                }
            }
        }

        //遍历二维数组
        for (int[] ints : arry) {
            for (int anInt : ints)
                System.out.print(anInt + "\t");
            System.out.println();
        }
    }
}
